<?php

namespace App\Repositories\Distribution;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Distribution\DistributionTimeRepository;
use App\Models\Distribution\DistributionTime;
use App\Validators\Distribution\DistributionTimeValidator;

/**
 * Class DistributionTimeRepositoryEloquent.
 *
 * @package namespace App\Repositories\Distribution;
 */
class DistributionTimeRepositoryEloquent extends BaseRepository implements DistributionTimeRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return DistributionTime::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return DistributionTimeValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    /**
     * 获取配送时间
     * @author Min
     * @param $mode_id
     * @return mixed
     */
    public function getDistributionTimeByModeId($mode_id)
    {
        $where = [
            'mode_id' => $mode_id
        ];

        $field = ['id','start_time','end_time','closing_time'];

        return $this->findWhere($where, $field)->toArray();
    }
    
}
